import { format } from 'date-fns';

const BriefCard = ({ brief }) => {
    if (!brief) return <div>None</div>;
    const {
        brief_title: briefTitle,
        brief_reason: briefReason,
        brief_source: briefSource,
        brief_date: briefDate
    } = brief;

    const formatedDate = format(briefDate, 'yyyy-MM-dd');
    const forartedToday = format(new Date(), 'yyyy-MM-dd');
    const lines = briefReason.split('；');
    return (
        <div className={`border border-gray-200 p-1 truncate`}>
            <p
                style={{
                    color: `${formatedDate === forartedToday ? 'violet' : 'yellow'}`
                }}
            >
                {formatedDate} | {briefSource.toUpperCase()} | {briefTitle}
            </p>
            {briefSource === 'gnn' ? (
                <p className="font-bold ">
                    {lines.map((line, index) => (
                        <span key={index}>
                            {line}
                            <br />
                        </span>
                    ))}
                </p>
            ) : null}
        </div>
    );
};
export default BriefCard;
